Vue Js Detect Browser Platform: Vue.js is a popular JavaScript library for creating web applications and can be used to detect the platform of the browser in which it is running .The navigator platform property returns a string that represents the platform used by the browser.we can identify the user’s device, whether it’s a mobile phone, tablet, laptop, or desktop computer.In this tutorial, we’ll look at how to get the user’s browser device using native javascript and vue js.
How to detect user browser platform in vue js?
With the help of native Javascript, we can use the navigator.platform property to get the user’s browser platform.
Vue Js Detect browser platform Name | Example
<div id="app">
<button @click="detectPlatform">click me</button>
<p>Browser platform : {{output}} </p>
</div>
<script type="module">
import { createApp } from "vue";
createApp({
data() {
return {
output: ''
}
},
methods: {
detectPlatform() {
this.output = navigator.platform;
}
}
}).mount("#app");
</script>